home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 1995 #2 / Amiga Plus CD - 1995 - No. 2.iso / startrek / trek73 / src / endgame.c < prev    next >
C/C++ Source or Header  |  1995-04-11  |  5KB  |  197 lines

  1. /*
  2.  * TREK73: endgame.c
  3.  *
  4.  * prints end-of-game messages and warnings
  5.  *
  6.  * leftovers, final, warn
  7.  *
  8.  */
  9.  
  10. #ifdef unix
  11. #include <sys/types.h>
  12. #include <sys/file.h>
  13. #endif
  14.  
  15. #include "defines.h"
  16. #include "structs.h"
  17.  
  18. extern char captain[];
  19. extern char title[];
  20. extern char science[];
  21. extern char com[];
  22. extern char helmsman[];
  23. extern char foerace[];
  24. extern char foename[];
  25. extern char foestype[];
  26. extern char empire[];
  27. extern int reengaged;
  28.  
  29. leftovers()
  30. {
  31.     extern    struct list head;
  32.     extern    struct list *tail;
  33.     register struct list *lp;
  34.  
  35.     for (lp = &head; lp != tail; lp = lp->fwd) {
  36.         if (lp->type == 0)
  37.             continue;
  38.         if (lp->type != I_SHIP)
  39.             return 1;
  40.     }
  41.     return 0;
  42. }
  43.  
  44.  
  45. final(mesg)
  46. int mesg;
  47. {
  48.     extern    struct ship *shiplist[];
  49.     extern    int shipnum;
  50.     register int i;
  51.     register int j;
  52.     struct    ship *sp;
  53.     struct    ship *ep;
  54.     char buf[80];
  55.     extern    char *plural();
  56.  
  57.  
  58.     sp = shiplist[0];
  59.     /* If we're getting that message again, ignore it. */
  60.     if ((mesg == 2) && (reengaged))
  61.         return;
  62.     switch (mesg) {
  63.     case 0:
  64.         starfleet();
  65.         printf("We have recieved confirmation that the USS %s,\n",
  66.             sp->name);
  67.         printf("   captained by %s, was destroyed by %s%s\n",captain, shipnum==1 ?"a ":"", foerace);
  68.         printf("   %s%s.  May future Federation officers\n", foestype, plural(shipnum));
  69.         printf("   perform better in their duties.\n\n");
  70.         break;
  71.     case 1:
  72.         starfleet();
  73.         printf("We commend Captain %s and his crew on their\n",captain);
  74.         printf("   fine performance against the %ss.  May he\n",foerace);
  75.         printf("   be an inspiration to future starship captains.\n");
  76.         break;
  77.     case 2:
  78.         /*
  79.          * Give him a chance to re-engage if he wants to.  If he does,
  80.          * he has to get within a range of 3500 before he can again
  81.          * try to dis-engage
  82.          */
  83.         if (!reengaged) {
  84.             printf("%s:  %s, we are in a position to either disengage from the\n", science, title);
  85.             printf("   %ss, or re-engage them in combat.\n", foerace);
  86.             printf("   Do you wish to re-engage?\n");
  87.             printf("%s: [y or n] ", captain);
  88.             gets(buf);
  89.             if ((*buf == NULL) || (*buf == 'y') || (*buf == 'Y')) {
  90.                 reengaged = 1;
  91.                 return;
  92.             }
  93.         }
  94.         starfleet();
  95.         printf("Captain %s of the starship %s has\n",captain,sp->name);
  96.         printf("   out-maneuvered %s aggressors.  We commend\n",foerace);
  97.         printf("   his tactical ability.\n");
  98.         break;
  99.     case 3:
  100.         starfleet();
  101.         printf("Captain %s of the starship %s has\n",captain,sp->name);
  102.         printf("   surrendered his vessel to the %ss.  May\n",foerace);
  103.         printf("   Captain Donsell be remembered.\n");
  104.         break;
  105.     case 4:
  106.         starfleet();
  107.         printf("We have recieved word from the %s that the\n",sp->name);
  108.         printf("   %ss have surrendered.\n",foerace);
  109.         break;
  110.     case 5:
  111.         starfleet();
  112.         printf("One of our vessels has encountered the wreckage of\n");
  113.         printf("   the %s and %d other %s vessel%s.\n", sp->name,
  114.             shipnum, foerace, plural(shipnum));
  115.         break;
  116.     default:
  117.         printf("how did we get here?\n");
  118.         break;
  119.     }
  120.     printf("\n\n");
  121.     j = 0;
  122.     for (i=0; i<=shipnum; i++) {
  123.         ep = shiplist[i];
  124.         if (ep->status & S_DEAD)
  125.             continue;
  126.         if (!j)
  127.             printf("Survivors Reported:\n");
  128.         j++;
  129.     }
  130.     if (j) {
  131.         for (i=0; i<=shipnum; i++) {
  132.             ep = shiplist[i];
  133.             if ((ep->status & S_DEAD) || (ep->crew == 0)){
  134.                 printf("   %s -- destroyed.\n",ep->name);
  135.                 }
  136.             else
  137.                 printf("   %s -- %d\n", ep->name, ep->crew);
  138.         }
  139.     } else
  140.         printf("*** No survivors reported ***\n");
  141.     exit (1);
  142. }
  143.  
  144.  
  145.  
  146. warn(mesg)
  147. int mesg;
  148. {
  149.     extern    struct ship *shiplist[];
  150.     static    int beenhere[5] = {0, 0, 0, 0, 0};
  151.     struct    ship *sp;
  152.  
  153.     if ((reengaged) && (mesg == 2)) {
  154.         return 0;
  155.     }
  156.     if (beenhere[mesg])
  157.         return 0;
  158.     sp = shiplist[0];
  159.     switch (mesg) {
  160.     case 0:
  161.         printf("Message to the Federation:  This is Commander\n");
  162.         printf("   %s of the %s %s.  We have defeated\n", foename, foerace, empire);
  163.         printf("   the %s and are departing the quadrant.\n", sp->name);
  164.         break;
  165.     case 1:
  166.         printf("%s: All %s vessels have been either\n", science, foerace);
  167.         printf("   destroyed or crippled.  We still, however, have\n");
  168.         printf("   antimatter devices to avoid.\n");
  169.         break;
  170.     case 2:
  171.         printf("%s: The %ss are falling behind and seem to\n", helmsman, foerace);
  172.         printf("   be breaking off their attack.\n");
  173.         break;
  174.     case 3:
  175.         printf("%s: I'm informing Starfleet Command of our \n", com);
  176.         printf("   disposition.\n");
  177.         break;
  178.     case 4:
  179.         printf("%s: Although the %ss have surrendered,\n",science, foerace);
  180.         printf("   there are still antimatter devices floating\n");
  181.         printf("   around us.\n");
  182.         break;
  183.     default:
  184.         printf("how did we get here?\n");
  185.         break;
  186.     }
  187.     beenhere[mesg]++;
  188.     return 0;
  189. }
  190.  
  191. starfleet()
  192. {
  193.     printf("\n\nStarfleet Command: \n");
  194.     sleep(3);
  195.     printf("\n");
  196. }
  197.